home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 January / enter-2004-01.iso / files / maxima-5.9.0.exe / {app} / info / maxima.info-13 < prev    next >
Encoding:
Text File  |  2003-02-09  |  47.7 KB  |  1,071 lines

  1. This is maxima.info, produced by makeinfo version 4.1 from maxima.texi.
  2.  
  3.    This is a Texinfo Maxima Manual
  4.  
  5.    Copyright 1994,2001 William F. Schelter
  6.  
  7. START-INFO-DIR-ENTRY
  8. * Maxima: (maxima).     A computer algebra system.
  9. END-INFO-DIR-ENTRY
  10.  
  11. 
  12. File: maxima.info,  Node: Definitions for Function Definition,  Prev: OPTIMIZATION,  Up: Function Definition
  13.  
  14. Definitions for Function Definition
  15. ===================================
  16.  
  17.  - Function: APPLY (function, list)
  18.      gives the result of applying the function to the list of its
  19.      arguments.  This is useful when it is desired to compute the
  20.      arguments to a function before applying that function.  For
  21.      example, if L is the list [1, 5, -10.2, 4, 3], then APPLY(MIN,L)
  22.      gives -10.2.  APPLY is also useful when calling functions which do
  23.      not have their arguments evaluated if it is desired to cause
  24.      evaluation of them.  For example, if FILESPEC is a variable bound
  25.      to the list [TEST, CASE] then APPLY(CLOSEFILE,FILESPEC) is
  26.      equivalent to CLOSEFILE(TEST,CASE).  In general the first argument
  27.      to APPLY should be preceded by a ' to make it evaluate to itself.
  28.      Since some atomic variables have the same name as certain
  29.      functions the values of the variable would be used rather than the
  30.      function because APPLY has its first argument evaluated as well as
  31.      its second.
  32.  
  33.  
  34.  - Function: BINDTEST (ai)
  35.      causes ai to signal an error if it ever is used in a computation
  36.      unbound.
  37.  
  38.  
  39.  - Function: BLOCK ([v1,...,vk], statement1,...,statementj)
  40.      Blocks in MACSYMA are somewhat analogous to subroutines in FORTRAN
  41.      or procedures in ALGOL or PL/I.  Blocks are like compound
  42.      statements but also enable the user to label statements within the
  43.      block and to assign "dummy" variables to values which are local to
  44.      the block.  The vi are variables which are local to the BLOCK and
  45.      the stmti are any MACSYMA expressions.  If no variables are to be
  46.      made local then the list may be omitted.  A block uses these local
  47.      variables to avoid conflict with variables having the same names
  48.      used outside of the block (i.e. global to the block).  In this
  49.      case, upon entry to the block, the global values are saved onto a
  50.      stack and are inaccessible while the block is being executed.  The
  51.      local variables then are unbound so that they evaluate to
  52.      themselves.  They may be bound to arbitrary values within the
  53.      block but when the block is exited the saved values are restored
  54.      to these variables.  The values created in the block for these
  55.      local variables are lost.  Where a variable is used within a block
  56.      and is not in the list of local variables for that block it will
  57.      be the same as the variable used outside of the block.      If it
  58.      is desired to save and restore other local properties besides
  59.      VALUE, for example ARRAY (except for complete arrays), FUNCTION,
  60.      DEPENDENCIES, ATVALUE, MATCHDECLARE, ATOMGRAD, CONSTANT, and
  61.      NONSCALAR then the function LOCAL should be used inside of the
  62.      block with arguments being the names of the variables.      The
  63.      value of the block is the value of the last statement or the value
  64.      of the argument to the function RETURN which may be used to exit
  65.      explicitly from the block. The function GO may be used to transfer
  66.      control to the statement of the block that is tagged with the
  67.      argument to GO.  To tag a statement, precede it by an atomic
  68.      argument as another statement in the BLOCK.  For example:
  69.      BLOCK([X],X:1,LOOP,X:X+1,...,GO(LOOP),...).  The argument to GO
  70.      must be the name of a tag appearing within the BLOCK.  One cannot
  71.      use GO to transfer to a tag in a BLOCK other than the one
  72.      containing the GO.      Blocks typically appear on the right side
  73.      of a function definition but can be used in other places as well.
  74.  
  75.  
  76.  - Function: BREAK (arg1, ...)
  77.      will evaluate and print its arguments and will then cause a
  78.      (MACSYMA-BREAK) at which point the user can examine and change his
  79.      environment.  Upon typing EXIT; the computation resumes.
  80.      Control-A (^A) will enter a MACSYMA-BREAK from any point
  81.      interactively.  EXIT; will continue the computation.  Control-X
  82.      may be used inside the MACSYMA-BREAK to quit locally, without
  83.      quitting the main computation.
  84.  
  85.  
  86.  - Macro: BUILDQ
  87.      - See DESCRIBE(MACROS); .
  88.  
  89.  
  90.  - Function: CATCH (exp1,...,expn)
  91.      evaluates its arguments one by one; if the structure of the expi
  92.      leads to the evaluation of an expression of the form THROW(arg),
  93.      then the value of the CATCH is the value of THROW(arg).  This
  94.      "non-local return" thus goes through any depth of nesting to the
  95.      nearest enclosing CATCH.  There must be a CATCH corresponding to a
  96.      THROW, else an error is generated.  If the evaluation of the expi
  97.      does not lead to the evaluation of any THROW then the value of the
  98.      CATCH is the value of expn.
  99.           (C1) G(L):=CATCH(MAP(LAMBDA([X],
  100.                  IF X<0 THEN THROW(X) ELSE F(X)),L));
  101.           (C2) G([1,2,3,7]);
  102.           (D2)                     [F(1), F(2), F(3), F(7)]
  103.           (C3) G([1,2,-3,7]);
  104.           (D3)                                - 3
  105.  
  106.      The function G returns a list of F of each element of L if L
  107.      consists only of non-negative numbers; otherwise, G "catches" the
  108.      first negative element of L and "throws" it up.
  109.  
  110.  
  111.  - Function: COMPFILE ([filespec], f1, f2, ..., fn)
  112.      Compiles functions fi into the file "filespec".  For convenience,
  113.      see the COMPILE function.
  114.  
  115.  
  116.  - Variable: COMPGRIND
  117.      default: [FALSE] when TRUE function definitions output by COMPFILE
  118.      are pretty-printed.
  119.  
  120.  
  121.  - Function: COMPILE (f)
  122.      The COMPILE command is a convenience feature in macsyma. It
  123.      handles the calling of the function COMPFILE, which translates
  124.      macsyma functions into lisp, the calling of the lisp compiler on
  125.      the file produced by COMPFILE, and the loading of the output of
  126.      the compiler, know as a FASL file, into the macsyma. It also
  127.      checks the compiler comment listing output file for certain common
  128.      errors.  Do PRINTFILE(MCOMPI,DOC,MAXDOC); for more details.
  129.      COMPILE(); causes macsyma to prompt for arguments.
  130.      COMPILE(function1,function2,...); compiles the functions, it uses
  131.      the name of function1 as the first name of the file to put the
  132.      lisp output.  COMPILE(ALL); or COMPILE(FUNCTIONS); will compile
  133.      all functions.  COMPILE([file-name],function1,function2,...); N.B.
  134.      all arguments are evaluated, just like a normal function (it is a
  135.      normal function!).  Therefore, if you have variables with the same
  136.      name as part of the file you can not ignore that fact.
  137.  
  138.  
  139.  - Function: COMPILE_LISP_FILE ("input filename")
  140.      which takes an optional second argument of "output filename," can
  141.      be used in conjunction with
  142.  
  143.           TRANSLATE_FILE("filename").
  144.      For convenience you might define
  145.  
  146.           Compile_and_load(FILENAME):=
  147.               LOAD(COMPILE_LISP_FILE(TRANSLATE_FILE(FILENAME)[2]))[2]);
  148.  
  149.      These file-oriented commands are to be preferred over the use of
  150.      COMPILE, COMPFILE, and the TRANSLATE SAVE combination.
  151.  
  152.  
  153.  - Function: DEFINE (f(x1, ...), body)
  154.      is equivalent to f(x1,...):="body but when used inside functions
  155.      it happens at execution time rather than at the time of definition
  156.      of the function which contains it.
  157.  
  158.  
  159.  - Function: DEFINE_VARIABLE
  160.           (name,default-binding,mode,optional-documentation)
  161.      introduces a global variable into the MACSYMA environment.  This is
  162.      for user-written packages, which are often translated or compiled.
  163.      Thus
  164.           DEFINE_VARIABLE(FOO,TRUE,BOOLEAN);
  165.      does the following:
  166.  
  167.      (1) MODE_DECLARE(FOO,BOOLEAN); sets it up for the translator.
  168.  
  169.      (2) If the variable is unbound, it sets it:  FOO:TRUE.
  170.  
  171.      (3) DECLARE(FOO,SPECIAL); declares it special.
  172.  
  173.      (4) Sets up an assign property for it to make sure that it never
  174.       gets set to a value of the wrong mode.      E.g.  FOO:44 would
  175.      be an error once FOO is defined BOOLEAN.
  176.  
  177.      See DESCRIBE(MODE_DECLARE); for a list of the possible "modes".
  178.      The optional 4th argument is a documentation string.  When
  179.      TRANSLATE_FILE is used on a package which includes documentation
  180.      strings, a second file is output in addition to the LISP file which
  181.      will contain the documentation strings, formatted suitably for use
  182.      in manuals, usage files, or (for instance) DESCRIBE.  With any
  183.      variable which has been DEFINE_VARIABLE'd with mode other than
  184.      ANY, you can give a VALUE_CHECK property, which is a function of
  185.      one argument called on the value the user is trying to set the
  186.      variable to.
  187.  
  188.           PUT('G5,LAMBDA([U],IF U#'G5 THEN ERROR("Don't set G5")),
  189.                  'VALUE_CHECK);
  190.  
  191.      Use DEFINE_VARIABLE(G5,'G5,ANY_CHECK, "this ain't supposed to be
  192.      set by anyone but me.")  ANY_CHECK is a mode which means the same
  193.      as ANY, but which keeps DEFINE_VARIABLE from optimizing away the
  194.      assign property.
  195.  
  196.  
  197.  - Function: DISPFUN (f1, f2, ...)
  198.      displays the definition of the user defined functions f1, f2, ...
  199.      which may also be the names of array associated functions,
  200.      subscripted functions, or functions with constant subscripts which
  201.      are the same as those used when the functions were defined.
  202.      DISPFUN(ALL) will display all user defined functions as given on
  203.      the FUNCTIONS and ARRAYS lists except subscripted functions with
  204.      constant subscripts.  E.g. if the user has defined a function
  205.      F(x), DISPFUN(F); will display the definition.
  206.  
  207.  
  208.  - Variable: FUNCTIONS
  209.      default: [] - all user defined functions (set up by f(x):=...).
  210.  
  211.  
  212.  - Function: FUNDEF (functionname)
  213.      returns the function definition associated with "functionname".
  214.      FUNDEF(fnname); is similar to DISPFUN(fnname); except that FUNDEF
  215.      does not invoke display.
  216.  
  217.  
  218.  - Function: FUNMAKE (name,[arg1,...,argn])
  219.      returns name(arg1,...,argn) without calling the function name.
  220.  
  221.  
  222.  - Function: LOCAL (v1, v2, ...)
  223.      causes the variables v1,v2,... to be local with respect to all the
  224.      properties in the statement in which this function is used.  LOCAL
  225.      may only be used in BLOCKs, in the body of function definitions or
  226.      LAMBDA expressions, or in the EV function and only one occurrence
  227.      is permitted in each.  LOCAL is independent of CONTEXT.
  228.  
  229.  
  230.  - Variable: MACROEXPANSION
  231.      default:[FALSE] - Controls advanced features which affect the
  232.      efficiency of macros. Possible settings:  FALSE - Macros expand
  233.      normally each time they are called.   EXPAND - The first time a
  234.      particular call is evaluated, the expansion is "remembered"
  235.      internally, so that it doesn't have to be recomputed on subsequent
  236.      calls making subsequent calls faster.  The macro call still GRINDs
  237.      and DISPLAYs normally, however extra memory is required to
  238.      remember all of the expansions.   DISPLACE - The first time a
  239.      particular call is evaluated, the expansion is substituted for the
  240.      call.  This requires slightly less storage than when
  241.      MACROEXPANSION is set to EXPAND and is just as fast, but has the
  242.      disadvantage that the original macro call is no longer remembered
  243.      and hence the expansion will be seen if DISPLAY or GRIND is
  244.      called.  See documentation for TRANSLATE and MACROS for more
  245.      details.
  246.  
  247.  
  248.  - Variable: MODE_CHECKP
  249.      default: [TRUE] - If TRUE, MODE_DECLARE checks the modes of bound
  250.      variables.
  251.  
  252.  
  253.  - Variable: MODE_CHECK_ERRORP
  254.      default: [FALSE] - If TRUE, MODE_DECLARE calls error.
  255.  
  256.  
  257.  - Variable: MODE_CHECK_WARNP
  258.      default: [TRUE] - If TRUE, mode errors are described.
  259.  
  260.  
  261.  - Function: MODE_DECLARE (y1, mode1, y2, mode2, ...)
  262.      MODEDECLARE is a synonym for this.  MODE_DECLARE is used to
  263.      declare the modes of variables and functions for subsequent
  264.      translation or compilation of functions. Its arguments are pairs
  265.      consisting of a variable yi, and a mode which is one of BOOLEAN,
  266.      FIXNUM, NUMBER, RATIONAL, or FLOAT.  Each yi may also be a list of
  267.      variables all of which are declared to have modei.  If yi is an
  268.      array, and if every element of the array which is referenced has a
  269.      value then ARRAY(yi, COMPLETE, dim1, dim2, ...)  rather than
  270.           ARRAY(yi, dim1, dim2, ...)
  271.      should be used when first declaring the bounds of the array.  If
  272.      all the elements of the array are of mode FIXNUM (FLOAT), use
  273.      FIXNUM (FLOAT) instead of COMPLETE.  Also if every element of the
  274.      array is of the same mode, say m, then
  275.  
  276.           MODE_DECLARE(COMPLETEARRAY(yi),m))
  277.      should be used for efficient translation.  Also numeric code using
  278.      arrays can be made to run faster by declaring the expected size of
  279.      the array, as in:
  280.  
  281.           MODE_DECLARE(COMPLETEARRAY(A[10,10]),FLOAT)
  282.  
  283.      for a floating point number array which is 10 x 10.  Additionally
  284.      one may declare the mode of the result of a function by using
  285.      FUNCTION(F1,F2,...) as an argument; here F1,F2,... are the names
  286.      of functions.  For example the expression,
  287.  
  288.           MODE_DECLARE([FUNCTION(F1,F2,...),X],FIXNUM,Q,
  289.                                           COMPLETEARRAY(Q),FLOAT)
  290.  
  291.      declares that X and the values returned by F1,F2,... are
  292.      single-word integers and that Q is an array of floating point
  293.      numbers.  MODE_DECLARE is used either immediately inside of a
  294.      function definition or at top-level for global variables.  Do
  295.      PRINTFILE(MCOMPI,DOC,MAXDOC); for some examples of the use of
  296.      MODE_DECLARE in translation and compilation.
  297.  
  298.  
  299.  - Function: MODE_IDENTITY (arg1,arg2)
  300.      A special form used with MODE_DECLARE and MACROS to delcare, e.g.,
  301.      a list of lists of flonums, or other compound data object.  The
  302.      first argument to MODE_IDENTITY is a primitive value mode name as
  303.      given to MODE_DECLARE (i.e. [FLOAT,FIXNUM,NUMBER, LIST,ANY]), and
  304.      the second argument is an expression which is evaluated and
  305.      returned as the value of MODE_IDENTITY.  However, if the return
  306.      value is not allowed by the mode declared in the first argument,
  307.      an error or warning is signalled.  The important thing is that the
  308.      MODE of the expression as determined by the MACSYMA to Lisp
  309.      translator, will be that given as the first argument, independent
  310.      of anything that goes on in the second argument.  E.g. X:3.3;
  311.      MODE_IDENTITY(FIXNUM,X); is an error.  MODE_IDENTITY(FLONUM,X)
  312.      returns 3.3 .  This has a number of uses, e.g., if you knew that
  313.      FIRST(L) returned a number then you might write
  314.      MODE_IDENTITY(NUMBER,FIRST(L)).  However, a more efficient way to
  315.      do it would be to define a new primitive,
  316.  
  317.           FIRSTNUMB(X)::=BUILDQ([X],MODE_IDENTITY(NUMBER,X));
  318.      and use FIRSTNUMB every time you take the first of a list of
  319.      numbers.
  320.  
  321.  
  322.  - Variable: TRANSBIND
  323.      default: [FALSE] - if TRUE removes global declarations in the
  324.      local context.  This applies to variables which are formal
  325.      parameters to functions which one is TRANSLATE-ing from MACSYMA
  326.      code to LISP.
  327.  
  328.  
  329.  - Variable: TRANSCOMPILE
  330.      default:[FALSE] - if true, TRANSLATE will generate the
  331.      declarations necessary for possible compilation.  The COMPFILE
  332.      command uses TRANSCOMPILE:TRUE;.
  333.  
  334.  
  335.  - Function: TRANSLATE (f1, f2, ...)
  336.      translates the user defined functions f1,f2,... from the MACSYMA
  337.      language to LISP (i.e. it makes them EXPRs).  This results in a
  338.      gain in speed when they are called.  There is now a version of
  339.      macsyma with the macsyma to lisp translator pre-loaded into it.
  340.      It is available by typing :TM (for TranslateMacsyma) at DDT level.
  341.      When given a file name, E.g. :TM GJC;TMTEST > , it gives that
  342.      file to the function TRANSLATE_FILE, and proceeds without further
  343.      user interaction.  If no file name is given, :TM gives a regular
  344.      macsyma "(C1)" line.  P.s. A user init file with second name "TM"
  345.      will be loaded if it exists.  You may just want to link this to
  346.      your macsyma init file.  Functions to be translated should include
  347.      a call to MODE_DECLARE at the beginning when possible in order to
  348.      produce more efficient code.  For example:
  349.  
  350.           F(X1,X2,...):=BLOCK([v1,v2,...],
  351.                   MODE_DECLARE(v1,mode1,v2,mode2,...),...)
  352.  
  353.      where the X1,X2,...  are the parameters to the function and the
  354.      v1,v2,... are the local variables.  The names of translated
  355.      functions are removed from the FUNCTIONS list if SAVEDEF is FALSE
  356.      (see below) and are added to the PROPS lists.  Functions should
  357.      not be translated unless they are fully debugged.  Also,
  358.      expressions are assumed simplified; if they are not, correct but
  359.      non- optimal code gets generated.  Thus, the user should not set
  360.      the SIMP switch to FALSE which inhibits simplification of the
  361.      expressions to be translated.  The switch TRANSLATE, default:
  362.      [FALSE], If TRUE, causes automatic translation of a user's
  363.      function to LISP.  Note that translated functions may not run
  364.      identically to the way they did before translation as certain
  365.      incompatabilities may exist between the LISP and MACSYMA versions.
  366.      Principally, the RAT function with more than one argument and the
  367.      RATVARS function should not be used if any variables are
  368.      MODE_DECLAREd CRE.  Also the PREDERROR:FALSE setting will not
  369.      translate.  SAVEDEF[TRUE] - if TRUE will cause the MACSYMA version
  370.      of a user function to remain when the function is TRANSLATEd.
  371.      This permits the definition to be displayed by DISPFUN and allows
  372.      the function to be edited.  TRANSRUN[TRUE] - if FALSE will cause
  373.      the interpreted version of all functions to be run (provided they
  374.      are still around) rather than the translated version.  One can
  375.      translate functions stored in a file by giving TRANSLATE an
  376.      argument which is a file specification.  This is a list of the form
  377.      [fn1,fn2,DSK,dir] where fn1 fn2 is the name of the file of MACSYMA
  378.      functions, and dir is the name of a file directory.  The result
  379.      returned by TRANSLATE is a list of the names of the functions
  380.      TRANSLATEd.  In the case of a file translation the corresponding
  381.      element of the list is a list of the first and second new file
  382.      names containing the LISP code resulting from the translation.
  383.      This will be fn1 LISP on the disk directory dir.  The file of LISP
  384.      code may be read into MACSYMA by using the LOADFILE function.
  385.  
  386.  
  387.  - Function: TRANSLATE_FILE (file)
  388.      translates a file of MACSYMA code into a file of LISP code.  It
  389.      takes one or two arguments.  The first argument is the name of the
  390.      MACSYMA file, and the optional second argument is the name of the
  391.      LISP file to produce.  The second argument defaults to the first
  392.      argument with second file name the value of TR_OUTPUT_FILE_DEFAULT
  393.      which defaults to TRLISP.  For example:
  394.      TRANSLATE_FILE("test.mc")); will translate "test.mc" to
  395.      "test.LISP".  Also produced is a file of translator warning
  396.      messages of various degrees of severity.  The second file name is
  397.      always UNLISP.  This file contains valuable (albeit obsure for
  398.      some) information for tracking down bugs in translated code.  Do
  399.      APROPOS(TR_) to get a list of TR (for TRANSLATE) switches.  In
  400.      summary, TRANSLATE_FILE("foo.mc"), LOADFILE("foo.LISP") is "=" to
  401.      BATCH("foo.mc") modulo certain restrictions (the use of " and % for
  402.      example).
  403.  
  404.  
  405.  - Variable: TRANSRUN
  406.      default: [TRUE] - if FALSE will cause the interpreted version of
  407.      all functions to be run (provided they are still around) rather
  408.      than the translated version.
  409.  
  410.  
  411.  - Variable: TR_ARRAY_AS_REF
  412.      default: [TRUE] - If TRUE runtime code uses the value of the
  413.      variable as the array.
  414.  
  415.  
  416.  - Variable: TR_BOUND_FUNCTION_APPLYP
  417.      default: [TRUE] - Gives a warning if a bound variable is found
  418.      being used as a function.
  419.  
  420.  
  421.  - Variable: TR_FILE_TTY_MESSAGESP
  422.      default: [FALSE] - Determines whether messages generated by
  423.      TRANSLATE_FILE during translation of a file will be sent to the
  424.      TTY.  If FALSE (the default), messages about translation of the
  425.      file are only inserted into the UNLISP file.  If TRUE, the messages
  426.      are sent to the TTY and are also inserted into the UNLISP file.
  427.  
  428.  
  429.  - Variable: TR_FLOAT_CAN_BRANCH_COMPLEX
  430.      default: [TRUE] - States whether the arc functions might return
  431.      complex results.  The arc functions are SQRT, LOG, ACOS, etc.
  432.      e.g. When it is TRUE then ACOS(X) will be of mode ANY even if X is
  433.      of mode FLOAT. When FALSE then ACOS(X) will be of mode FLOAT if
  434.      and only if X is of mode FLOAT.
  435.  
  436.  
  437.  - Variable: TR_FUNCTION_CALL_DEFAULT
  438.      default: [GENERAL] - FALSE means give up and call MEVAL, EXPR
  439.      means assume Lisp fixed arg function.  GENERAL, the default gives
  440.      code good for MEXPRS and MLEXPRS but not MACROS.  GENERAL assures
  441.      variable bindings are correct in compiled code.  In GENERAL mode,
  442.      when translating F(X), if F is a bound variable, then it assumes
  443.      that APPLY(F,[X]) is meant, and translates a such, with apropriate
  444.      warning. There is no need to turn this off.  With the default
  445.      settings, no warning messages implies full compatibility of
  446.      translated and compiled code with the macsyma interpreter.
  447.  
  448.  
  449.  - Variable: TR_GEN_TAGS
  450.      default: [FALSE] - If TRUE, TRANSLATE_FILE generates a TAGS file
  451.      for use by the text editor.
  452.  
  453.  
  454.  - Variable: TR_NUMER
  455.      default: [FALSE] - If TRUE numer properties are used for atoms
  456.      which have them, e.g. %PI.
  457.  
  458.  
  459.  - Variable: TR_OPTIMIZE_MAX_LOOP
  460.      default: [100] - The maximum number of times the macro-expansion
  461.      and optimization pass of the translator will loop in considering a
  462.      form.  This is to catch MACRO expansion errors, and
  463.      non-terminating optimization properties.
  464.  
  465.  
  466.  - Variable: TR_OUTPUT_FILE_DEFAULT
  467.      default: [TRLISP] - This is the second file name to be used for
  468.      translated lisp output.
  469.  
  470.  
  471.  - Variable: TR_PREDICATE_BRAIN_DAMAGE
  472.      default: [FALSE] - If TRUE, output possible multiple evaluations
  473.      in an attempt to interface to the COMPARE package.
  474.  
  475.  
  476.  - Variable: TR_SEMICOMPILE
  477.      default: [FALSE] - If TRUE TRANSLATE_FILE and COMPFILE output
  478.      forms which will be macroexpanded but not compiled into machine
  479.      code by the lisp compiler.
  480.  
  481.  
  482.  - Variable: TR_STATE_VARS
  483.      default:
  484.           [TRANSCOMPILE, TR_SEMICOMPILE,
  485.           TR_WARN_UNDECLARED, TR_WARN_MEVAL, TR_WARN_FEXPR, TR_WARN_MODE,
  486.           TR_WARN_UNDEFINED_VARIABLE, TR_FUNCTION_CALL_DEFAULT,
  487.            TR_ARRAY_AS_REF,TR_NUMER]
  488.      The list of the switches that affect the form of the translated
  489.      output.  This information is useful to system people when trying
  490.      to debug the translator.  By comparing the translated product to
  491.      what should have been produced for a given state, it is possible to
  492.      track down bugs.
  493.  
  494.  
  495.  - Variable: TR_TRUE_NAME_OF_FILE_BEING_TRANSLATED
  496.      default: [FALSE] is bound to the quoted string form of the true
  497.      name of the file most recently translated by TRANSLATE_FILE.
  498.  
  499.  
  500.  - Variable: TR_VERSION
  501.      - The version number of the translator.
  502.  
  503.  
  504.  - Function: TR_WARNINGS_GET ()
  505.      Prints a list of warnings which have been given by the translator
  506.      during the current translation.
  507.  
  508.  
  509.  - Variable: TR_WARN_BAD_FUNCTION_CALLS
  510.      default: [TRUE] - Gives a warning when when function calls are
  511.      being made which may not be correct due to improper declarations
  512.      that were made at translate time.
  513.  
  514.  
  515.  - Variable: TR_WARN_FEXPR
  516.      default: [COMPFILE] - Gives a warning if any FEXPRs are
  517.      encountered.  FEXPRs should not normally be output in translated
  518.      code, all legitimate special program forms are translated.
  519.  
  520.  
  521.  - Variable: TR_WARN_MEVAL
  522.      default: [COMPFILE] - Gives a warning if the function MEVAL gets
  523.      called.  If MEVAL is called that indicates problems in the
  524.      translation.
  525.  
  526.  
  527.  - Variable: TR_WARN_MODE
  528.      default: [ALL] - Gives a warning when variables are assigned
  529.      values inappropriate for their mode.
  530.  
  531.  
  532.  - Variable: TR_WARN_UNDECLARED
  533.      default: [COMPILE] - Determines when to send warnings about
  534.      undeclared variables to the TTY.
  535.  
  536.  
  537.  - Variable: TR_WARN_UNDEFINED_VARIABLE
  538.      default: [ALL] - Gives a warning when undefined global variables
  539.      are seen.
  540.  
  541.  
  542.  - Variable: TR_WINDY
  543.      default: [TRUE] - Generate "helpfull" comments and programming
  544.      hints.
  545.  
  546.  
  547.  - Variable: UNDECLAREDWARN
  548.      default: [COMPFILE] - A switch in the Translator.  There are four
  549.      relevant settings: SETTING     | ACTION
  550.      ----------------------------------------------------------- FALSE
  551.          | never print warning messages.  COMPFILE    | warn when in
  552.      COMPFILE TRANSLATE   | warn when in TRANSLATE and when
  553.      TRANSLATE:TRUE ALL         | warn in COMPFILE and TRANSLATE
  554.      ----------------------------------------------------------- Do
  555.      MODE_DECLARE(<variable>,ANY) to declare a variable to be a general
  556.      macsyma variable (i.e. not limited to being FLOAT or FIXNUM).  The
  557.      extra work in declaring all your variables in code  to be compiled
  558.      should pay off.
  559.  
  560.  
  561.  - Function: COMPILE_FILE (filename,&optional-outfile)
  562.      It takes filename which contains macsyma code, and translates this
  563.      to lisp and then compiles the result.  It returns a list of four
  564.      files (the original file,translation, notes on translation and the
  565.      compiled code).
  566.  
  567.  
  568.  - Function: DECLARE_TRANSLATED (FN1,FN2..)
  569.      When translating a file of macsyma code to lisp, it is important
  570.      for the translator to know which functions it sees in the file are
  571.      to be called as translated or compiled functions, and which ones
  572.      are just macsyma functions or undefined.  Putting this declaration
  573.      at the top of the file, lets it know that although a symbol does
  574.      which does not yet have a lisp function value, will have one at
  575.      call time.  (MFUNCTION-CALL fn arg1 arg2.. ) is generated when the
  576.      translator does not know fn is going to be a lisp function.
  577.  
  578.  
  579. 
  580. File: maxima.info,  Node: Program Flow,  Next: Debugging,  Prev: Function Definition,  Up: Top
  581.  
  582. Program Flow
  583. ************
  584.  
  585. * Menu:
  586.  
  587. * Introduction to Program Flow::
  588. * Definitions for Program Flow::
  589.  
  590. 
  591. File: maxima.info,  Node: Introduction to Program Flow,  Next: Definitions for Program Flow,  Prev: Program Flow,  Up: Program Flow
  592.  
  593. Introduction to Program Flow
  594. ============================
  595.  
  596.    MACSYMA provides a DO loop for iteration, as well as more primitive
  597. constructs such as GO.
  598.  
  599. 
  600. File: maxima.info,  Node: Definitions for Program Flow,  Prev: Introduction to Program Flow,  Up: Program Flow
  601.  
  602. Definitions for Program Flow
  603. ============================
  604.  
  605.  - Variable: BACKTRACE
  606.      default: [] (when DEBUGMODE:ALL has been done) has as value a list
  607.      of all functions currently entered.
  608.  
  609.  
  610.  - special operator: DO
  611.      - The DO statement is used for performing iteration.  Due to its
  612.      great generality the DO statement will be described in two parts.
  613.      First the usual form will be given which is analogous to that used
  614.      in several other programming languages (FORTRAN, ALGOL, PL/I,
  615.      etc.); then the other features will be mentioned.  1.  There are
  616.      three variants of this form that differ only in their terminating
  617.      conditions.  They are:
  618.         * (a)  FOR variable : initial-value STEP increment       THRU
  619.           limit DO body
  620.  
  621.         * (b)  FOR variable : initial-value STEP increment       WHILE
  622.           condition DO body
  623.  
  624.         * (c)  FOR variable : initial-value STEP increment       UNLESS
  625.           condition DO body
  626.      (Alternatively, the STEP may be given after the termination
  627.      condition or limit.)      The initial-value, increment, limit, and
  628.      body can be any expressions.  If the increment is 1 then "STEP 1"
  629.      may be omitted.      The execution of the DO statement proceeds by
  630.      first assigning the initial-value to the variable (henceforth
  631.      called the control-variable). Then: (1) If the control-variable
  632.      has exceeded the limit of a THRU specification, or if the
  633.      condition of the UNLESS is TRUE, or if the condition of the WHILE
  634.      is FALSE then the DO terminates. (2) The body is evaluated.  (3)
  635.      The increment is added to the control-variable.  The process from
  636.      (1) to (3) is performed repeatedly until the termination condition
  637.      is satisfied.  One may also give several termination conditions in
  638.      which case the DO terminates when any of them is satisfied.
  639.      In general the THRU test is satisfied when the control-variable is
  640.      greater than the limit if the increment was non-negative, or when
  641.      the control-variable is less than the limit if the increment was
  642.      negative.  The increment and limit may be non-numeric expressions
  643.      as long as this inequality can be determined.  However, unless the
  644.      increment is syntactically negative (e.g. is a negative number) at
  645.      the time the DO statement is input, MACSYMA assumes it will be
  646.      positive when the DO is executed.  If it is not positive, then the
  647.      DO may not terminate properly.      Note that the limit,
  648.      increment, and termination condition are evaluated each time
  649.      through the loop.  Thus if any of these involve much computation,
  650.      and yield a result that does not change during all the executions
  651.      of the body, then it is more efficient to set a variable to their
  652.      value prior to the DO and use this variable in the DO form.
  653.      The value normally returned by a DO statement is the atom DONE, as
  654.      every statement in MACSYMA returns a value.  However, the function
  655.      RETURN may be used inside the body to exit the DO prematurely and
  656.      give it any desired value.  Note however that a RETURN within a DO
  657.      that occurs in a BLOCK will exit only the DO and not the BLOCK.
  658.      Note also that the GO function may not be used to exit from a DO
  659.      into a surrounding BLOCK.      The control-variable is always
  660.      local to the DO and thus any variable may be used without
  661.      affecting the value of a variable with the same name outside of
  662.      the DO.  The control-variable is unbound after the DO terminates.
  663.           (C1)   FOR A:-3 THRU 26 STEP 7 DO LDISPLAY(A)$
  664.           (E1)          A = -3
  665.           (E2)          A =  4
  666.           (E3)          A = 11
  667.           (E4)          A = 18
  668.           (E5)          A = 25
  669.      The function LDISPLAY generates intermediate labels; DISPLAY does
  670.      not.
  671.           (C6)   S:0$
  672.           (C7)   FOR I:1 WHILE I<=10 DO S:S+I;
  673.           (D7)          DONE
  674.           (C8)   S;
  675.           (D8)          55
  676.      Note that the condition in C7 is equivalent to UNLESS I > 10 and
  677.      also THRU 10
  678.           (C9)   SERIES:1$
  679.           (C10)  TERM:EXP(SIN(X))$
  680.           (C11)  FOR P:1 UNLESS P>7 DO
  681.                     (TERM:DIFF(TERM,X)/P,
  682.                     SERIES:SERIES+SUBST(X=0,TERM)*X^P)$
  683.           (C12)   SERIES;
  684.                           7    6     5    4    2
  685.           (D12)          X    X     X    X    X
  686.                          -- - --- - -- - -- + -- + X + 1
  687.                          96   240   15   8    2
  688.           which gives 8 terms of the Taylor series for e^sin(x).
  689.           (C13) POLY:0$
  690.           (C14) FOR I:1 THRU 5 DO
  691.                   FOR J:I STEP -1 THRU 1 DO
  692.                      POLY:POLY+I*X^J$
  693.           (C15) POLY;
  694.                         5      4       3       2
  695.           (D15)      5 X  + 9 X  + 12 X  + 14 X  + 15 X
  696.           (C16) GUESS:-3.0$
  697.           (C17) FOR I:1 THRU 10 DO (GUESS:SUBST(GUESS,X,.5*(X+10/X)),
  698.                    IF ABS(GUESS^2-10)<.00005 THEN RETURN(GUESS));
  699.           (D17)                  - 3.1622807
  700.  
  701.      This example computes the negative square root of 10 using the
  702.      Newton- Raphson iteration a maximum of 10 times.  Had the
  703.      convergence criterion not been met the value returned would have
  704.      been "DONE".  Additional Forms of the DO Statement     Instead of
  705.      always adding a quantity to the control-variable one may sometimes
  706.      wish to change it in some other way for each iteration.  In this
  707.      case one may use "NEXT expression" instead of "STEP increment".
  708.      This will cause the control-variable to be set to the result of
  709.      evaluating expression each time through the loop.
  710.  
  711.           (C1)  FOR COUNT:2 NEXT 3*COUNT THRU 20
  712.                    DO DISPLAY(COUNT)$
  713.                               COUNT = 2
  714.                               COUNT = 6
  715.                               COUNT = 18
  716.  
  717.      As an alternative to FOR variable:value ...DO... the syntax FOR
  718.      variable FROM value ...DO...  may be used.  This permits the "FROM
  719.      value" to be placed after the step or next value or after the
  720.      termination condition.  If "FROM value" is omitted then 1 is used
  721.      as the initial value.      Sometimes one may be interested in
  722.      performing an iteration where the control-variable is never
  723.      actually used.  It is thus permissible to give only the
  724.      termination conditions omitting the initialization and updating
  725.      information as in the following example to compute the square-root
  726.      of 5 using a poor initial guess.
  727.           (C1) X:1000;
  728.           (C2)  THRU 10 WHILE X#0.0 DO X:.5*(X+5.0/X)$
  729.           (C3) X;
  730.           (D3)               2.236068
  731.          If it is desired one may even omit the termination conditions
  732.      entirely and just give "DO body" which will continue to evaluate
  733.      the body indefinitely.  In this case the function RETURN should be
  734.      used to terminate execution of the DO.
  735.           (C1) NEWTON(F,GUESS):=
  736.             BLOCK([NUMER,Y],
  737.                   LOCAL(DF),
  738.                   NUMER:TRUE,
  739.                   DEFINE(DF(X),DIFF(F(X),X)),
  740.                   DO (Y:DF(GUESS),
  741.                       IF Y=0.0 THEN ERROR("Derivative at:",GUESS," is zero."),
  742.                       GUESS:GUESS-F(GUESS)/Y,
  743.                       IF ABS(F(GUESS))<5.0E-6 THEN RETURN(GUESS)))$
  744.           (C2) SQR(X):=X^2-5.0$
  745.           (C3) NEWTON(SQR,1000);
  746.           (D3)                    2.236068
  747.          (Note that RETURN, when executed, causes the current value of
  748.      GUESS to be returned as the value of the DO.  The BLOCK is exited
  749.      and this value of the DO is returned as the value of the BLOCK
  750.      because the DO is the last statement in the block.)      One other
  751.      form of the DO is available in MACSYMA.  The syntax is:
  752.  
  753.           FOR variable IN list [end-tests] DO body
  754.          The members of the list are any expressions which will
  755.      successively be assigned to the variable on each iteration of the
  756.      body.  The optional end-tests can be used to terminate execution of
  757.      the DO; otherwise it will terminate when the list is exhausted or
  758.      when a RETURN is executed in the body.  (In fact, list may be any
  759.      non-atomic expression, and successive parts are taken.)
  760.  
  761.           (C1)  FOR F IN [LOG, RHO, ATAN] DO LDISP(F(1))$
  762.           (E1)                                  0
  763.           (E2)                                RHO(1)
  764.                                                %PI
  765.           (E3)                                 ---
  766.                                                 4
  767.           (C4) EV(E3,NUMER);
  768.           (D4)                             0.78539816
  769.  
  770.  - Function: ERRCATCH (exp1, exp2, ...)
  771.      evaluates its arguments one by one and returns a list of the value
  772.      of the last one if no error occurs.  If an error occurs in the
  773.      evaluation of any arguments, ERRCATCH "catches" the error and
  774.      immediately returns [] (the empty list).  This function is useful
  775.      in BATCH files where one suspects an error might occur which would
  776.      otherwise have terminated the BATCH if the error weren't caught.
  777.  
  778.  
  779.  - Variable: ERREXP
  780.      default: [ERREXP] When an error occurs in the course of a
  781.      computation, MACSYMA prints out an error message and terminates the
  782.      computation.  ERREXP is set to the offending expression and the
  783.      message "ERREXP contains the offending expression" is printed.  The
  784.      user can then type ERREXP; to see this and hopefully find the
  785.      problem.
  786.  
  787.  
  788.  - Function: ERROR (arg1, arg2, ...)
  789.      will evaluate and print its arguments and then will cause an error
  790.      return to top level MACSYMA or to the nearest enclosing ERRCATCH.
  791.      This is useful for breaking out of nested functions if an error
  792.      condition is detected, or wherever one can't type control-^.  The
  793.      variable ERROR is set to a list describing the error, the first of
  794.      it being a string of text, and the rest the objects in question.
  795.      ERRORMSG(); is the preferred way to see the last error message.
  796.      ERRORFUN default: [FALSE] - if set to the name of a function of no
  797.      arguments will cause that function to be executed whenever an error
  798.      occurs.  This is useful in BATCH files where the user may want his
  799.      MACSYMA killed or his terminal logged out if an error occurs.  In
  800.      these cases ERRORFUN would be set to QUIT or LOGOUT.
  801.  
  802.  
  803.  - Variable: ERRORFUN
  804.      default: [FALSE] - if set to the name of a function of no
  805.      arguments will cause that function to be executed whenever an error
  806.      occurs.  This is useful in BATCH files where the user may want his
  807.      MACSYMA killed or his terminal logged out if an error occurs.  In
  808.      these cases ERRORFUN would be set to QUIT or LOGOUT.
  809.  
  810.  
  811.  - Function: ERRORMSG ()
  812.      reprints the last error message.  This is very helpful if you are
  813.      using a display console and the message has gone off the screen.
  814.      The variable ERROR is set to a list describing the error, the
  815.      first of it being a string of text, and the rest the objects in
  816.      question.  TTYINTFUN:LAMBDA([],ERRORMSG(),PRINT(""))$ will set up
  817.      the user-interrupt character (^U) to reprint the message.
  818.  
  819.  
  820.  - special operator: FOR
  821.      - Used in iterations, do DESCRIBE("DO"); for a description of
  822.      MACSYMA's iteration facilities.
  823.  
  824.  
  825.  - Function: GO (tag)
  826.      is used within a BLOCK to transfer control to the statement of the
  827.      block which is tagged with the argument to GO.  To tag a
  828.      statement, precede it by an atomic argument as another statement in
  829.      the BLOCK.  For example:
  830.           BLOCK([X],X:1,LOOP,X+1,...,GO(LOOP),...)
  831.      .  The argument to GO must be the name of a tag appearing in the
  832.      same BLOCK.  One cannot use GO to transfer to tag in a BLOCK other
  833.      than the one containing the GO.
  834.  
  835.  
  836.  - special operator: IF
  837.      - The IF statement is used for conditional execution.  The syntax
  838.      is:
  839.               IF condition THEN expression1 ELSE expression2.
  840.      The result of an IF statement is expression1 if condition is true
  841.      and expression2 if it is false.  expression1 and expression2 are
  842.      any MACSYMA expressions (including nested IF statements), and
  843.      condition is an expression which evaluates to TRUE or FALSE and is
  844.      composed of relational and logical operators which are as follows:
  845.  
  846.           Operator name       Symbol      Type
  847.           greater than        >           relational infix
  848.           equal to            = , EQUAL   "  "
  849.           not equal to        #           "  "
  850.           less than           <           "  "
  851.           greater than        >=
  852.             or equal to                   "  "
  853.           less than           <=
  854.             or equal to                   "  "
  855.           and                 AND         logical infix
  856.           or                  OR          "  "
  857.           not                 NOT         logical prefix
  858.  
  859.  - Function: LISPDEBUGMODE ()
  860.      LISPDEBUGMODE(); DEBUGPRINTMODE(); and DEBUG(); make available to
  861.      the user debugging features used by systems programmers.  These
  862.      tools are powerful, and although some conventions are different
  863.      from the usual macsyma level it is felt their use is very
  864.      intuitive.  [Some printout may be verbose for slow terminals,
  865.      there are switches for controlling this.]  These commands were
  866.      designed for the user who must debug translated macsyma code, as
  867.      such they are a boon.  See MACDOC;TRDEBG USAGE for more
  868.      information.
  869.  
  870.  
  871.  - Function: MAP (fn, exp1, exp2, ...)
  872.      returns an expression whose leading operator is the same as that
  873.      of the expi but whose subparts are the results of applying fn to
  874.      the corresponding subparts of the expi.  Fn is either the name of
  875.      a function of n arguments (where n is the number of expi) or is a
  876.      LAMBDA form of n arguments.  MAPERROR[TRUE] - if FALSE will cause
  877.      all of the mapping functions to (1) stop when they finish going
  878.      down the shortest expi if not all of the expi are of the same
  879.      length and (2) apply fn to [exp1, exp2,...]  if the expi are not
  880.      all the same type of object. If MAPERROR is TRUE then an error
  881.      message will be given in the above two instances.  One of the uses
  882.      of this function is to MAP a function (e.g. PARTFRAC) onto each
  883.      term of a very large expression where it ordinarily wouldn't be
  884.      possible to use the function on the entire expression due to an
  885.      exhaustion of list storage space in the course of the computation.
  886.           (C1) MAP(F,X+A*Y+B*Z);
  887.           (D1)                        F(B Z) + F(A Y) + F(X)
  888.           (C2) MAP(LAMBDA([U],PARTFRAC(U,X)),X+1/(X^3+4*X^2+5*X+2));
  889.                                      1       1        1
  890.           (D2)                     ----- - ----- + -------- + X
  891.                                    X + 2   X + 1          2
  892.                                                    (X + 1)
  893.           (C3) MAP(RATSIMP, X/(X^2+X)+(Y^2+Y)/Y);
  894.                                                 1
  895.           (D3)                            Y + ----- + 1
  896.                                               X + 1
  897.           (C4) MAP("=",[A,B],[-0.5,3]);
  898.           (D4)                          [A = - 0.5, B = 3]
  899.  
  900.  - Function: MAPATOM (expr)
  901.      is TRUE if and only if expr is treated by the MAPping routines as
  902.      an "atom", a unit.  "Mapatoms" are atoms, numbers (including
  903.      rational numbers), and subscripted variables.
  904.  
  905.  
  906.  - Variable: MAPERROR
  907.      default: [TRUE] - if FALSE will cause all of the mapping
  908.      functions, for example
  909.           MAP(fn,exp1,exp2,...))
  910.      to (1) stop when they finish going down the shortest expi if not
  911.      all of the expi are of the same length and (2) apply fn to [exp1,
  912.      exp2,...] if the expi are not all the same type of object.  If
  913.      MAPERROR is TRUE then an error message will be given in the above
  914.      two instances.
  915.  
  916.  
  917.  - Function: MAPLIST (fn, exp1, exp2, ...)
  918.      yields a list of the applications of fn to the parts of the expi.
  919.      This differs from MAP(fn,exp1,exp2,...)  which returns an
  920.      expression with the same main operator as expi has (except for
  921.      simplifications and the case where MAP does an APPLY).  Fn is of
  922.      the same form as in MAP.
  923.  
  924.  
  925.  - Variable: PREDERROR
  926.      default: [TRUE] - If TRUE, an error message is signalled whenever
  927.      the predicate of an IF statement or an IS function fails to
  928.      evaluate to either TRUE or FALSE.  If FALSE, UNKNOWN is returned
  929.      instead in this case.  The PREDERROR:FALSE mode is not supported in
  930.      translated code.
  931.  
  932.  
  933.  - Function: RETURN (value)
  934.      may be used to exit explicitly from a BLOCK, bringing its
  935.      argument.  Do DESCRIBE(BLOCK); for more information.
  936.  
  937.  
  938.  - Function: SCANMAP (function,exp)
  939.      recursively applies function to exp, in a "top down" manner.  This
  940.      is most useful when "complete" factorization is desired, for
  941.      example:
  942.           (C1) EXP:(A^2+2*A+1)*Y + X^2$
  943.           (C2) SCANMAP(FACTOR,EXP);
  944.                                               2      2
  945.           (D2)                         (A + 1)  Y + X
  946.  
  947.      Note the way in which SCANMAP applies the given function FACTOR to
  948.      the constituent subexpressions of exp; if another form of exp is
  949.      presented to SCANMAP then the result may be different.  Thus, D2
  950.      is not recovered when SCANMAP is applied to the expanded form of
  951.      exp:
  952.           (C3) SCANMAP(FACTOR,EXPAND(EXP));
  953.                                      2                  2
  954.           (D3)                      A  Y + 2 A Y + Y + X
  955.  
  956.      Here is another example of the way in which SCANMAP recursively
  957.      applies a given function to all subexpressions, including
  958.      exponents:
  959.           (C4) EXPR : U*V^(A*X+B) + C$
  960.           (C5) SCANMAP('F, EXPR);
  961.                               F(F(F(A) F(X)) + F(B))
  962.           (D5) F(F(F(U) F(F(V)                      )) + F(C))
  963.      SCANMAP(function,expression,BOTTOMUP) applies function to exp in a
  964.      "bottom-up" manner.  E.g., for undefined F,
  965.  
  966.           SCANMAP(F,A*X+B) ->
  967.              F(A*X+B) -> F(F(A*X)+F(B)) -> F(F(F(A)*F(X))+F(B))
  968.           SCANMAP(F,A*X+B,BOTTOMUP) -> F(A)*F(X)+F(B)
  969.               -> F(F(A)*F(X))+F(B) ->
  970.                F(F(F(A)*F(X))+F(B))
  971.  
  972.      In this case, you get the same answer both ways.
  973.  
  974.  
  975.  - Function: THROW (exp)
  976.      evaluates exp and throws the value back to the most recent CATCH.
  977.      THROW is used with CATCH as a structured nonlocal exit mechanism.
  978.  
  979.  
  980. 
  981. File: maxima.info,  Node: Debugging,  Next: Function and Variable Index,  Prev: Program Flow,  Up: Top
  982.  
  983. Debugging
  984. *********
  985.  
  986. * Menu:
  987.  
  988. * Source Level Debugging::
  989. * Keyword Commands::
  990. * Definitions for Debugging::
  991.  
  992. 
  993. File: maxima.info,  Node: Source Level Debugging,  Next: Keyword Commands,  Up: Debugging
  994.  
  995. Source Level Debugging
  996. ======================
  997.  
  998.    Maxima has source level capabilities.  A user can set a breakpoint at
  999. a line in a file, and then step line by line from there.  The call
  1000. stack may be examined, together with the variables bound at that level.
  1001. If the user is running the code under GNU emacs in a shell window (dbl
  1002. shell), or is running `xmaxima' the graphical interface version, then
  1003. if he stops at a break point, he will see his current position in the
  1004. source file which will be displayed in the other half of the window,
  1005. either highlighted in red, or with a little arrow pointing at the right
  1006. line.  He can advance single lines at a time by typing M-n (Alt-n) or
  1007. alternately by entering `:n'.  To see the names of the keyword commands
  1008. type :help (or :h).  In general commands may be abbreviated if the
  1009. abbreviation is unique.  If not unique the alternatives will be listed.
  1010.  
  1011.    Under Emacs you should run in a `dbl' shell, which requires the
  1012. dbl.el file in the elisp directory.  Make sure you install the elisp
  1013. files or add the maxima elisp directory to your path: eg add the
  1014. following to your `.emacs' file or the `site-init.el'
  1015.  
  1016.      (setq load-path (cons "/usr/local/maxima-5.5/elisp" load-path))
  1017.      (autoload 'dbl "dbl")
  1018.    then in emacs
  1019.      M-x dbl
  1020.    should start a shell window in which you can run programs, for
  1021. example maxima, gcl, gdb etc.   This shell window also knows about
  1022. source level debugging, and display of source code in the other window.
  1023.  
  1024.      maxima
  1025.      Maxima 5.5 Wed Apr 18 19:02:00 CDT 2001 (with enhancements by W. Schelter).
  1026.      Licensed under the GNU Public License (see file COPYING)
  1027.      (C1) batchload("/tmp/joe.mac");
  1028.      (D1)                  /tmp/joe.mac
  1029.      (C2) :br joe
  1030.      Turning on debugging debugmode(true)
  1031.      Bkpt 0 for joe (in /tmp/joe.mac line 8)
  1032.      (C2) foo(2,3);
  1033.      Bkpt 0:(joe.mac 8)
  1034.      (dbm:1) :bt                        <-- :bt typed here gives a backtrace
  1035.      #0: joe(y=5)(joe.mac line 8)
  1036.      #1: foo(x=2,y=3)(joe.mac line 5)
  1037.      (joe.mac 9)                        <-- Here type M-n to advance line
  1038.      (joe.mac 10)                       <-- Here type M-n to advance line
  1039.                                         In the other buffer the source code
  1040.                                         appears with an arrow.
  1041.      (dbm:1) u;                         Investigate value of 'u
  1042.      28
  1043.      (dbm:1) u:33;                      Alter it to be 33
  1044.      (dbm:1) :r                         :r Resumes the computation
  1045.      (D3)                      1094
  1046.  
  1047.    The actual file /tmp/joe.mac is the following:
  1048.  
  1049.      foo(x,y):=(
  1050.        x:x+2,
  1051.        y:y+2,
  1052.        x:joe(y),
  1053.        x+y);
  1054.      
  1055.      joe(y):=block([u:y^2],
  1056.        u:u+3,
  1057.        u:u^2,
  1058.         u);
  1059.  
  1060.    If you are running in Gnu Emacs then if you are looking at the file
  1061. joe.mac, you may set a break point at a certain line of that file by
  1062. typing `C-x space'.  This figures out which function your cursor is in,
  1063. and then it sees which line of that function you are on.   If you are
  1064. on say line 2 of joe, then it will insert in the other window `:br joe
  1065. 2' the command to break joe at its second line.   To have this enabled
  1066. you must have maxima-mode.el on in the window in which the file joe.mac
  1067. is visiting.  There are additional commands available in that file
  1068. window, such as evaluating the function into the maxima, by typing
  1069. `Alt-Control-x'
  1070.  
  1071.